package com.handinglian.ai.system.service.impl;

import com.handinglian.ai.system.entity.UserRoleRelation;
import com.handinglian.ai.system.mapper.UserRoleRelationMapper;
import com.handinglian.ai.system.service.UserRoleRelationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class UserRoleRelationServiceImpl implements UserRoleRelationService {
    @Autowired
    private UserRoleRelationMapper userRoleRelationMapper;

    @Override
    @Transactional
    public int create(UserRoleRelation record) {
        return userRoleRelationMapper.insertSelective(record);
    }

    @Override
    public List<UserRoleRelation> list(Integer roleId) {
        return userRoleRelationMapper.findByRoleId(roleId);
    }

    @Override
    public UserRoleRelation get(Integer userId) {
        return userRoleRelationMapper.findOneByUserId(userId);
    }

    @Override
    @Transactional
    public int update(UserRoleRelation record) {
        return userRoleRelationMapper.updateByPrimaryKeySelective(record);
    }
}
